Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
style-unit
Advanced tools
Unit conversion for calculating dimensional css attributes, especially for rpx.
convertUnit(value, prop, platform);
Property | Type | Required | Description |
---|---|---|---|
value | string/number | true | |
prop | string | true | |
platform | string | false | Different platforms have different rpx conversion. Details are as follows. |
In Web, Calculate rpx to vw (relative to viewport width 750).
750rpx -> 100vw
You can use setViewportWidth
method update viewport width
setViewportWidth(1500);
750rpx -> 50vw
In Web, Calculate rpx to px (viewport width is 750).
750rpx -> 750px
You can use setRpx
method update coefficient of 750
setRpx(1500 / 750)
750rpx -> 1500px
rpx (responsive pixel): Adaptable to the screen width in MiniApp. The specified screen width is 750 rpx. If the screen width on iPhone6 is 375 px (750 physical pixels), then 750 rpx = 375 px = 750 physical pixels, i.e. 1 rpx = 0.5 px = 1 physical pixel.
Use Weex result:
convertUnit('500rpx', 'width', 'weex')
Use Web result:
convertUnit('500rpx', 'width', 'web')
FAQs
style-unit
The npm package style-unit receives a total of 1,546 weekly downloads. As such, style-unit popularity was classified as popular.
We found that style-unit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.